package com.zhiyou100.inner_demo;

/**
 * 汽车类
 *
 */
public class Car {
    private String name;  //型号
    private double price; //价钱
    //引擎  内部类
    public class Engine {
        //排量
        private double displacement;
        private String name;  //型号

        public double getDisplacement() {
            return displacement;
        }

        public void setDisplacement(double displacement) {
            this.displacement = displacement;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Engine(double displacement, String name) {
            this.displacement = displacement;
            this.name = name;
        }

        public void startUp(){
            System.out.println(name + "型号的" + displacement + "引擎启动");
        }
        public void say(){
            System.out.println("排量" + displacement + "型号是" + name);
        }
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public void say(Engine engine){
        System.out.println(name + "价格" + price);
        engine.say();
    }
}
